package cn.tanghom.baiding.web.system.ctrl;

import cn.tanghom.baiding.api.system.model.User;
import cn.tanghom.baiding.api.system.service.UserService;
import cn.tanghom.baiding.core.controller.BaseController;
import cn.tanghom.baiding.core.page.Page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.annotation.Resource;

/**
 * 用户管理控制层
 *
 * @author tanghom
 */
@Controller
@RequestMapping("/user")
public class UserController extends BaseController {

    @Resource
    private UserService userService;

    /**
     * @param model
     * @param userName
     * @param loginName
     * @param orgId
     * @return
     */
    @RequestMapping(value = "/list", method = {RequestMethod.POST, RequestMethod.GET})
    public String list(Model model, String userName, String loginName, Long orgId, Integer status,Long pageNo) {
        User user = new User();
        user.setUserName(userName);
        user.setLoginName(loginName);
        user.setOrganizationId(orgId);
        user.setStatus(status);
//        List<User> page = userService.selectTByT(user);
        Page<User> pageU = new Page<User>();
        pageU.setIndex(pageNo);
        Page<User> page = userService.selectTByPage(pageU,user);
        model.addAttribute("page", page);
        return "/system/user/list";
    }

}
